package com.simon.mengkou.future.handler;

import android.content.Context;

import com.ouertech.android.agm.lib.base.future.http.HttpEvent;
import com.simon.mengkou.future.base.OuerHttpHandler;
import com.simon.mengkou.system.global.OuerApplication;
import com.simon.mengkou.system.global.OuerDispatcher;

/**
 * Created by xiazhenshui on 16/7/27.
 */

public class AddCartHandler extends OuerHttpHandler {

    public AddCartHandler(Context context) {
        super(context);
    }

    @Override
    public void onHandle(HttpEvent evt) throws Exception {
        Boolean flag = (Boolean) evt.getData();
        if(flag) {
            int count = OuerApplication.mPreferences.getCartProductNum() + 1;
            OuerApplication.mPreferences.setCartProductNum(count);
            OuerDispatcher.sendAddCartBroadcast(mContext, count);
        }

        evt.getFuture().commitComplete(flag);
    }
}
